import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Home',
        meta: {
            auth: true,
            title:''
        },
        component: () => import(/* webpackChunkName: "about" */ '../views/home/index.vue'),
        children: [
            {
                path: '/mactivity',
                name: 'MActivity',
                meta: {
                    title: '导航一',
                    menu: 'MActivity'
                },
                component: () => import(/* webpackChunkName: "mall" */ '../views/home/mall/activity/index.vue')
            },
            {
              path: '/timedtask',
              name:'Timedtask',
              meta: {
                  menu:'Timedtask',
                  title:'导航二'
              },
              component: () =>
                  import(
                      /* webpackChunkName: "tool" */ '../views/home/mall/timedtask/index.vue'
                  )
          },
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import(/* webpackChunkName: "Login" */ '../views/login/index.vue')
    },
    {
        path: '/notfind',
        name: 'Notfind',
        component: () => import(/* webpackChunkName: "Notfind" */ '../views/notfind/index.vue')
    },
    {
        path: '/:pathMath(.*)',
        redirect: '/notfind'
    }
];

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
});
// router.beforeEach((to, form, next) => {
//     if (to.meta.auth) {
//         if (localStorage.getItem('TOKEN')) {
//             next();
//         } else {
//             next({ path: '/login' });
//         }
//     } else {
//         next();
//     }
// });

export default router;
